package com.biz.primus.ms.geo.dao.repository;

import com.biz.primus.base.enums.CommonStatus;
import com.biz.primus.ms.base.jpa.repository.CommonJpaRepository;
import com.biz.primus.ms.geo.dao.po.District;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author JKLiues
 * @date 2017/11/8
 */
@Repository
public interface DistrictRepository extends CommonJpaRepository<District, Integer>, DistrictDao {

    /**
     * 根据城市id查询区/县信息
     *
     * @param cityId   城市id
     * @param pageable 分页
     * @return 区/县 po集合
     */
    @Query("from District district where district.cityId = ?1 order by district.idx")
    Page<District> findDistrictsByCityId(Integer cityId, Pageable pageable);

    /**
     * 根据状态查区域
     *
     * @param status 状态
     * @return List<District>
     */
    List<District> findByStatus(CommonStatus status);
}
